package com.api.douyin.controller;

import com.alibaba.fastjson.JSONObject;
import com.api.douyin.util.DouYinApi;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 测试入口
 */
@ApiModel("抖音接口")
@Controller
@RequestMapping("/douyin")
public class DouYinController {

    @ApiOperation(value="扫码授权")
    @GetMapping("/code")
    public String toCode(){
        String client_key = "awdhwtrv28chvdx1";
        String response_type = "code";
        String scope = "user_info,video.create,video.delete,video.data,video.list,following.list,fans.list,fans.check";
        String redirect_uri = "https://ts.hebeitour.com.cn/hbyjy/image/bg.jpg";
        String state = "1";
        String url = "https://open.douyin.com/platform/oauth/connect?"+"client_key=" + client_key +
                "&response_type=" + response_type +
                "&scope=" + scope +
                "&redirect_uri=" + redirect_uri;
        return "redirect:"+url;
    }

    @ApiOperation(value="获取token")
    @ResponseBody
    @GetMapping("/token")
    public String getToken() {
        String token = DouYinApi.getToken();
        return token;
    }

    @ApiOperation(value="获取粉丝列表")
    @ResponseBody
    @GetMapping("/fans/list")
    public String getFans() {
        String fans = DouYinApi.getFans("10098264-068f-467b-b6a0-13c379e64dce",0, 10, "act.2dae4d4104a4b74f1cadc7d363383cec6YP5RsLcxWXoEWWGaAT9sLz6Xrkf");
        return fans;
    }
}
